pacman::p_load(sp, sf, rgdal, spNetwork, tmap, readr)1 Network Constrained Spatial Point Pattern Analysis
1.1 Project Overview
Network constrained Spatial Point Patterns Analysis (NetSPAA) is a collection of spatial point patterns analysis methods special developed for analysing spatial point event occurs on or alongside network.
The spatial point event can be locations of childcare centre for example.
The network, on the other hand can be a road network for example.
More information with regards to data sources used for this project can be found at the proposal
1.2 Installing the R packages
In this project, x packages will be used
1.3 Data Import and Preparation
1.3.1 Melbourne Road Network
Importing of shapefile, converting to EPSG of 7855 and converting Geometry Type to LINGSTRING.
road_network <- st_read("data/geospatial/Roads Network", layer = "road-corridors")Reading layer `road-corridors' from data source
`C:\Users\Ming Rong\Desktop\IS415 Project\spatial-bros\data\geospatial\Roads Network'
using driver `ESRI Shapefile'
Simple feature collection with 4177 features and 9 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: 144.897 ymin: -37.85066 xmax: 144.9913 ymax: -37.77545
Geodetic CRS: WGS 84
road_network <- st_transform(road_network, crs = 7855)
road_network_lines <- st_boundary(road_network) %>%
st_cast("LINESTRING")Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
Warning in st_cast.MULTILINESTRING(X[[i]], ...): keeping first linestring only
1.3.2 Melbourne Pedestrian Network
pedestrian_network <- st_read("data/geospatial/Pedestrian Network/pedestrian-network.geojson")Reading layer `pedestrian-network' from data source
`C:\Users\Ming Rong\Desktop\IS415 Project\spatial-bros\data\geospatial\Pedestrian Network\pedestrian-network.geojson'
using driver `GeoJSON'
Simple feature collection with 85326 features and 3 fields
Geometry type: GEOMETRY
Dimension: XY
Bounding box: xmin: 144.8993 ymin: -37.85074 xmax: 144.9918 ymax: -37.77547
Geodetic CRS: WGS 84
1.3.3 Tram Network
tram_network <- st_read("data/geospatial/Trams Network", layer = "PTV_METRO_TRAM_ROUTE")Reading layer `PTV_METRO_TRAM_ROUTE' from data source
`C:\Users\Ming Rong\Desktop\IS415 Project\spatial-bros\data\geospatial\Trams Network'
using driver `ESRI Shapefile'
Simple feature collection with 82 features and 12 fields
Geometry type: LINESTRING
Dimension: XY
Bounding box: xmin: 144.878 ymin: -37.91422 xmax: 145.182 ymax: -37.67898
Geodetic CRS: GDA2020
1.3.4 Localities
localities = st_read("data/geospatial/Localities", layer = "UCL_2021_AUST_GDA2020") Reading layer `UCL_2021_AUST_GDA2020' from data source
`C:\Users\Ming Rong\Desktop\IS415 Project\spatial-bros\data\geospatial\Localities'
using driver `ESRI Shapefile'
Simple feature collection with 1837 features and 12 fields (with 19 geometries empty)
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 96.81695 ymin: -43.7405 xmax: 167.998 ymax: -9.142163
Geodetic CRS: GDA2020
melbourne_localities <- localities[localities$UCL_NAME21 == "Melbourne", ]1.3.5 Local Government Areas
local_government_areas = st_read("data/geospatial/Local Government Areas", layer = "LGA_2022_AUST_GDA2020")Reading layer `LGA_2022_AUST_GDA2020' from data source
`C:\Users\Ming Rong\Desktop\IS415 Project\spatial-bros\data\geospatial\Local Government Areas'
using driver `ESRI Shapefile'
Simple feature collection with 566 features and 10 fields (with 19 geometries empty)
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 96.81695 ymin: -43.7405 xmax: 167.998 ymax: -9.142163
Geodetic CRS: GDA2020
melbourne_local_government_areas = local_government_areas[local_government_areas$LGA_NAME22 == "Melbourne",]1.3.6 Business Establishments Spatial Point
business_est_sp_point <- st_read("data/geospatial/Business Establishments Spatial Point/business-establishments-with-address-and-industry-classification.geojson")Reading layer `business-establishments-with-address-and-industry-classification' from data source `C:\Users\Ming Rong\Desktop\IS415 Project\spatial-bros\data\geospatial\Business Establishments Spatial Point\business-establishments-with-address-and-industry-classification.geojson'
using driver `GeoJSON'
replacing null geometries with empty geometries
Simple feature collection with 354556 features and 12 fields (with 4786 geometries empty)
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 144.8985 ymin: -37.85138 xmax: 144.9906 ymax: -37.77586
Geodetic CRS: WGS 84
1.3.7 Drinking Fountain Spatial Point
drinking_fountain_sp_point <- st_read("data/geospatial/Drinking Fountain Spatial Point", layer = "drinking-fountains")Reading layer `drinking-fountains' from data source
`C:\Users\Ming Rong\Desktop\IS415 Project\spatial-bros\data\geospatial\Drinking Fountain Spatial Point'
using driver `ESRI Shapefile'
Simple feature collection with 302 features and 3 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 144.9159 ymin: -37.84521 xmax: 144.991 ymax: -37.77712
Geodetic CRS: WGS 84
1.3.8 Landmarks Spatial Point
landmarks_sp_point <- st_read("data/geospatial/Landmarks Spatial Point", layer = "landmarks-and-places-of-interest-including-schools-theatres-health-services-spor")Reading layer `landmarks-and-places-of-interest-including-schools-theatres-health-services-spor' from data source `C:\Users\Ming Rong\Desktop\IS415 Project\spatial-bros\data\geospatial\Landmarks Spatial Point'
using driver `ESRI Shapefile'
Simple feature collection with 242 features and 3 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 144.9082 ymin: -37.84852 xmax: 144.9894 ymax: -37.78127
Geodetic CRS: WGS 84
1.3.9 Residential Dwellings Spatial Point
residential_dwelling_sp_point <- st_read("data/geospatial/Residential Dwellings Spatial Point/residential-dwellings.geojson")Reading layer `residential-dwellings' from data source
`C:\Users\Ming Rong\Desktop\IS415 Project\spatial-bros\data\geospatial\Residential Dwellings Spatial Point\residential-dwellings.geojson'
using driver `GeoJSON'
replacing null geometries with empty geometries
Simple feature collection with 188160 features and 11 fields (with 2869 geometries empty)
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 144.905 ymin: -37.84798 xmax: 144.9908 ymax: -37.77583
Geodetic CRS: WGS 84
1.3.10 Childcare Centres Spatial Point
childcare_sp_point <- read_csv("data/geospatial/Childcare Centres Spatial Point/childcare-centres.csv")Rows: 29 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): name, contact_ph, url
dbl (3): ref, lat, lon
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
1.3.10.1 Creating a simple feature data frame from Childcare Centres Spatial Point listings
Upon research, it was found that EPSG: 4326 is wGS84 Geographic Coordinate System, therefore we have to convert it to Melbourne’s GDA2020 / MGA zone 55 – EPSG:7855 (https://parametricmonkey.com/2020/04/08/understanding-australias-coordinate-systems/)
childcare_sp_point_sf <- st_as_sf(childcare_sp_point,
coords = c("lon", "lat"),
crs=4326) %>%
st_transform(crs = 7855)1.3.10.2 Converting to Spatial Point Data Frame
childcare_spdf <- as(childcare_sp_point_sf, "Spatial")
childcare_spdfclass : SpatialPointsDataFrame
features : 29
extent : 316811.7, 322956.8, 5809281, 5816727 (xmin, xmax, ymin, ymax)
crs : +proj=utm +zone=55 +south +ellps=GRS80 +units=m +no_defs
variables : 4
names : ref, name, contact_ph, url
min values : 100083, Alfred Child Care Centre, 03 8344 9621, http://emcc.org.au/yarra.php
max values : 717144, Yarra Park Children's Centre, 9820 2758, http://www.wimblest.com.au
1.3.11 Public Toilets Spatial Point
public_toilets_sp_point <- read_csv("data/geospatial/Public Toilets Spatial Point/public-toilets.csv")Rows: 74 Columns: 8
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (6): name, female, male, wheelchair, operator, baby_facil
dbl (2): lat, lon
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
list(public_toilets_sp_point) [[1]]
# A tibble: 74 × 8
name female male wheel…¹ opera…² baby_…³ lat lon
<chr> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl>
1 Public Toilet - Toilet 140 … no yes no City o… no -37.8 145.
2 Public Toilet - Toilet 6 - … yes no no City o… no -37.8 145.
3 Public Toilet - Toilet 142 … no yes no City o… no -37.8 145.
4 Public Toilet - Royal Park … yes yes no City o… no -37.8 145.
5 Public Toilet - Toilet 177 … yes yes yes City o… no -37.8 145.
6 Public Toilet - Toilet 118 … yes yes yes City o… no -37.8 145.
7 Public Toilet - Toilet 34 -… yes yes yes City o… no -37.8 145.
8 Public Toilet - Town Hall M… yes yes yes City o… yes -37.8 145.
9 Public Toilet - Toilet 131 … yes yes yes City o… no -37.8 145.
10 Public Toilet - Toilet 146 … yes no no City o… no -37.8 145.
# … with 64 more rows, and abbreviated variable names ¹wheelchair, ²operator,
# ³baby_facil
1.3.11.1 Creating a simple feature data frame from Public Toilets Spatial Point listings
Upon research, it was found that EPSG: 4326 is wGS84 Geographic Coordinate System, therefore we have to convert it to Melbourne’s GDA2020 / MGA zone 55 – EPSG:7855 (https://parametricmonkey.com/2020/04/08/understanding-australias-coordinate-systems/)
public_toilets_sp_point_sf <- st_as_sf(public_toilets_sp_point,
coords = c("lon", "lat"),
crs=4326) %>%
st_transform(crs = 7855)1.3.11.2 Converting to Spatial Point Data Frame
public_toilets_spdf <- as(public_toilets_sp_point_sf, "Spatial")
public_toilets_spdfclass : SpatialPointsDataFrame
features : 74
extent : 316969.7, 322790.1, 5809443, 5816753 (xmin, xmax, ymin, ymax)
crs : +proj=utm +zone=55 +south +ellps=GRS80 +units=m +no_defs
variables : 6
names : name, female, male, wheelchair, operator, baby_facil
min values : Public Toilet - Newmarket Reserve (26 Smithfield Road), no, no, no, City of Melbourne, no
max values : Public Toilet - Victoria Harbour, Shed 3 (North Wharf Road), yes, yes, yes, City of Melbourne, yes
1.4 Visualising the Geospatial Data
1.4.1 Melbourne road network with childcare centre
tmap_mode('view')tmap mode set to interactive viewing
tm_basemap(server = "OpenStreetMap") +
tm_shape(childcare_spdf) +
tm_dots(size = 0.03) +
tm_shape(road_network_lines) +
tm_lines()